package pos.domain;

import java.util.*;
import pos.data.*;

public class CalleProcessor implements ICalleProcessor{
	
	private List<String> listaCalles;
	private JDBCCalleDAO calleDao;
	private static CalleProcessor instance;
	
	public static synchronized CalleProcessor getInstance() {
        if (instance == null)
        	instance = new CalleProcessor();
        return instance;
    }
	
	@Override
	public List<String> getData(String query) {
		query = query.toLowerCase();
		List<Calle> lista = new ArrayList<Calle>();
		lista = calleDao.selectListByNombre(query);
		for(Calle c:lista){
			listaCalles.add(c.getNombre());
		}
		return listaCalles;
	}

	public CalleProcessor() {
		listaCalles = new ArrayList<String>();
		calleDao = new JDBCCalleDAO();
	}

	@Override
	public Calle getCalleByNombre(String nombre) {
		// TODO Auto-generated method stub
		Calle calle = calleDao.selectByNombre(nombre);
		return calle;
	}
	
	

}
